//
//  LiveViewController.m
//  YLProject
//
//  Created by 王跃 on 2018/1/10.
//  Copyright © 2018年 WY. All rights reserved.
//

#import "LiveViewController.h"
#import "LBSementBarVC.h"
#import "Live_HotController.h"
#import "Live_NewController.h"
#import "Live_FollowController.h"
#import "Live_NearbyController.h"
#import "Live_NewPeopleController.h"
@interface LiveViewController ()
@property (nonatomic, strong) LBSementBarVC *segmentBarVC;
@end

@implementation LiveViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.title = @"直播";
    //导航右按钮
    [self setUpNav];
    //导航滑动
    [self segmentbar];
}
-(void)segmentbar{
    self.segmentBarVC.segmentBar.frame = CGRectMake(0, 0, Screen_Width, 35);
    self.segmentBarVC.view.frame = self.view.bounds;
    //添加选项卡的基本设置
    [self.segmentBarVC.segmentBar updateWithConfig:^(LBSegmentBarConfig *config) {
        config.itemNC(kHEXCOLOR(@"#5a4c4c")).itemSC([UIColor redColor]).indicatorEW(10).itemBackgroundColorBlock([UIColor whiteColor]).itemFontBlock([UIFont systemFontOfSize:14]);
    }];
    
    [self.view addSubview:self.segmentBarVC.view];
    [self addChildViewController:self.segmentBarVC];
    [self.view addSubview:self.segmentBarVC.segmentBar];
    
    NSArray *items = @[@"热门", @"附近", @"最新",@"新人",@"关注"];
    
    // 添加几个自控制器
    // 在contentView, 展示子控制器的视图内容
    Live_HotController *vc1 = [Live_HotController new];
    Live_NearbyController *vc2 = [Live_NearbyController new];
    Live_NewController *vc3 = [Live_NewController new];
    Live_NewPeopleController *vc4 = [Live_NewPeopleController new];
    Live_FollowController *vc5 = [Live_FollowController new];
    [self.segmentBarVC setUpWithItems:items childViewControllers:@[vc1, vc2, vc3, vc4, vc5]];
    
}
-(void)setUpNav{
    UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
    rightButton.frame = CGRectMake(0, 5,34,34);
    [rightButton setBackgroundImage:[UIImage imageNamed:@"排行_highlight"] forState:UIControlStateNormal];
    [[rightButton  rac_signalForControlEvents:UIControlEventTouchUpInside]subscribeNext:^(__kindof UIControl * _Nullable x) {
        NSLog(@"直播右按钮");
    }];
    self.navigationItem.rightBarButtonItems = @[[[UIBarButtonItem alloc]initWithCustomView:rightButton]];
}
- (LBSementBarVC *)segmentBarVC {
    if (!_segmentBarVC) {
        _segmentBarVC = [[LBSementBarVC alloc] init];
        [self addChildViewController:_segmentBarVC];
    }
    return _segmentBarVC;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
